package com.example.wanbaqian.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.example.wanbaqian.R;
import com.example.wanbaqian.bean.MemberInfo;
import com.example.wanbaqian.utils.BaseUtils;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2017/4/6 0006.
 * 发现会员代理排行适配器
 */

public class FindMemberAdapter extends CommonAdapter<MemberInfo> {


    public FindMemberAdapter(final Context context, List<MemberInfo> datas) {
        super(context, R.layout.item_findlist, datas);
    }

    @Override
    protected void convert(ViewHolder holder, MemberInfo item, int position) {
        BaseUtils.loadImageForUserIcon(mContext, item.getAvatar_url(), (ImageView) holder.getView(R.id.iv_CustomImageView));
        holder.setVisible(R.id.iv_lv, (0 <= position && position < 3) ? true : false);
        holder.setVisible(R.id.iv_position, (0 <= position && position < 3) ? false : true);
        holder.setImageResource(R.id.iv_lv, position == 0 ? R.drawable.find_1 : position == 1 ? R.drawable.find_2 : R.drawable.find_3);
        holder.setText(R.id.iv_position, position + 1 + "");
        holder.setText(R.id.xiaoke_saleprice, null == item.getTotal_credit_loan() ? item.getAgent_prize() : item.getTotal_credit_loan());
        holder.setText(R.id.tv_name, TextUtils.isEmpty(item.getNick_name()) ? item.getLogin_mobile() : item.getNick_name());
        holder.setText(R.id.xiaoke_people_nums, item.getUser_level().equals("0") ? "普通会员" : item.getUser_level().equals("1") ? "铜牌会员" : item.getUser_level().equals("2") ? "银牌会员" : item.getUser_level().equals("3") ? "黄金会员" : "钻石会员");
    }

}
